//
//  ZZCNeedAssetsController.m
//  ZZC-Finance
//
//  Created by a on 2017/6/14.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "ZZCNeedAssetsController.h"

@interface ZZCNeedAssetsController ()<UINavigationControllerDelegate,UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *needAssetWebV;

@end

@implementation ZZCNeedAssetsController
#pragma mark - UINavigationControllerDelegate
// 将要显示控制器
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 判断要显示的控制器是否是自己
    BOOL isShowHomePage = [viewController isKindOfClass:[self class]];
    
    [self.navigationController setNavigationBarHidden:isShowHomePage animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    float chacha = [[NSUserDefaults standardUserDefaults] floatForKey:@"appchacha"];
    chacha += 0.02;
    [[NSUserDefaults standardUserDefaults] setFloat:chacha forKey:@"appchacha"];

    self.navigationController.delegate = self;
    // Do any additional setup after loading the view from its nib.
    self.needAssetWebV.delegate = self;
    self.needAssetWebV.scrollView.bounces = NO;
    NSString *token = ZZCNSUserDefaults(@"token");
    NSURL *h5_needAsset = [NSURL URLWithString:[NSString stringWithFormat:@"%@?token=%@",ZZCURL_API_H5_ASSET,token]];
    NSURLRequest *request = [NSURLRequest requestWithURL:h5_needAsset];
    NSLog(@"%@",h5_needAsset);
    //让内容自动适应屏幕大小
    self.needAssetWebV.scalesPageToFit = YES;
    [self.needAssetWebV loadRequest:request];
    [self.view addSubview:_needAssetWebV];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    NSLog(@"%@",request);
    if ([request.URL.absoluteString containsString:@"http://www.stlh.com/action===back"]) {
        NSLog(@"已拦截");
        [self.navigationController popToRootViewControllerAnimated:YES];
        
        
        return NO;
        
    }
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
